import App from './App'

// #ifndef VUE3
import Vue from 'vue'
import './uni.promisify.adaptor'

// vuex 仓库 store
import store from './store/index.js'
Vue.prototype.$store = store

Vue.config.productionTip = false
App.mpType = 'app'
const app = new Vue({
  ...App,
  store
})
app.$mount()
// #endif


import config from '@/common/config.js'
// api
Vue.prototype.$api = config.appurl;
Vue.prototype.$url = config.cdnurl;

// 图片
const appstc = (url) => {
	return config.url + url;
}
// back
const back = (val)=>{
	uni.navigateBack(val)
}
// tab
const tab = (index)=>{
	let list = [
		"/pages/index/index",
		"/pages/products/products",
		"/pages/store/store",
		"/pages/cart/cart",
		"/pages/user/user"
	]
	let url = list[index];
	uni.switchTab({
		url:url
	})
}
// 时间格式化处理
const formatDate = (value) => {
	const data = new Date(value);
	const month = data.getMonth() + 1;
	const day = data.getDate();
	const year = data.getFullYear();
	const hours = data.getHours();
	const minutes = data.getMinutes();
	const seconds = data.getSeconds();
	const formattedTime = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
	return formattedTime;
}
// 处理热卖多少件
const hotbuyShow = (value) => {
	if (value >= 10000) {
		let val = value / 10000
		// console.log(app.$t)
		return ` ${val} 万+ `
	} else if (value >= 1000) {
		let val = value / 1000
		return ` ${val} 千+ `
	} else {
		return value
	}
}

const isnum = 1

// #ifdef VUE3
import { createSSRApp } from 'vue'
export function createApp() {
  const app = createSSRApp(App)
  return {
    app
	
  }
}
// #endif

Vue.prototype.$daiyueapp = {
	appstc,
	formatDate,
	back,
	hotbuyShow,
	isnum,
	tab,

	
};